import React, { Component } from "react";

//引入路由
import { Router, Redirect, Route, Switch } from "react-router-dom";
import history from "utils/history";

//引入页面组件
import Layout from "pages/Layout/idnex";
import Login from "pages/Login/index";
import NotFound from "pages/NotFound/index";

//通用组件
import AuthRouter from "components/AuthRouter";

export default class App extends Component {
  render() {
    return (
      <Router history={history}>
        <Switch>
          <Redirect from="/" to="/Layout" exact></Redirect>
          <Route
            path="/Login"
            render={(props) => {
              if (localStorage.getItem("geek_pc")) props.history.push("/");
              else return <Login {...props}></Login>;
            }}
          ></Route>
          <AuthRouter
            path="/Layout"
            component={Layout}
            to="/Login"
          ></AuthRouter>
          <Route component={NotFound}></Route>
        </Switch>
      </Router>
    );
  }
}
